package com.gzk.oeno.business.compare;

import java.util.Comparator;

import com.gzk.oeno.business.cave.Cave;

public class CaveComparator implements Comparator<Cave>{

	private final NameComparator nameComparator = new NameComparator();
	
	@Override
	public int compare(Cave o1, Cave o2) {
		if (o1 == null && o2 == null)
			return 0;
		if (o1 == null)
			return 1;
		if (o2 == null)
			return -1;
		int proprio = nameComparator.compare(o1.getProprietaire(), o2.getProprietaire());
		if (proprio == 0){
			return o1.getName().compareToIgnoreCase(o2.getName());
		}
		return proprio;
	}

}
